#ifndef __DATASTRUCT_H__
#define __DATASTRUCT_H__

#include "CSVector.h"
#include "CSList.h"
#include "CSHashMap.h"
#include "CSString.h"
#include "../Memory/PieceMemPool.h"



struct MemoryStruct
{
	static void* Malloc(unsigned int size) 
	{
		return GPieceMem.Malloc(size);
	}
	static void Free(void* ptr) 
	{
		GPieceMem.Free(ptr);
	}
};

template<class T> 
class CSVector:public CSVectorBase<T,MemoryStruct,4> {};

template<class T> 
class CSList:public CSListBase<T,MemoryStruct> {};

template <class K,class V>
class CSHashMap:public CSHashMapBase<K,V,MemoryStruct,32> {};

typedef CSStringBase<MemoryStruct,4> CSString;

template<int MapSize>
class HashCode<CSString,MapSize>
{
public:
	static int Get(CSString& key)
	{
		static unsigned int Mask = MapSize-1;
		int ret=0;
		unsigned int tmp = 0;
		for(int i=0;i<key.GetSize();++i)
		{
			tmp+=key[i];
		}
		ret=tmp&Mask;
		return ret;
	}
	static bool Cmp(CSString& k1,CSString& k2)
	{
		return k1==k2;
	}
};

#endif

